<template>
  <div class="home-view">
    <!-- 主功能区 -->
    <section class="features-section">
      <div class="container">
        <div class="feature-grid">
          <router-link to="/appointment" class="feature-card feature-primary" v-animate-on-scroll>
            <i class="fas fa-calendar-check feature-icon"></i>
            <h3 class="feature-title">预约挂号</h3>
            <p class="feature-description">快速预约专家门诊，节省候诊时间</p>
            <div class="btn btn-white">
              立即预约
            </div>
          </router-link>
          <router-link to="/aiDoctor" class="feature-card feature-secondary" v-animate-on-scroll>
            <i class="fas fa-robot feature-icon"></i>
            <h3 class="feature-title">AI智能导诊</h3>
            <p class="feature-description">智能分析症状，精准推荐科室</p>
            <div class="btn btn-white">
              开始导诊
            </div>
          </router-link>
        </div>
      </div>
    </section>
    <!-- 所有一级科室 -->
    <section class="all-departments-section">
      <div class="container">
        <div class="section-header">
          <h2 class="section-title" v-animate-on-scroll>医院科室一览</h2>
          <p class="section-subtitle" v-animate-on-scroll>
            选择科室，快速找到您需要的医疗服务
          </p>
        </div>
        <div class="departments-grid">
          <div 
            v-for="(dept, index) in allDepartments" 
            :key="dept.id" 
            class="dept-card"
            v-animate-on-scroll
            :class="`delay-${(index % 3) + 1}`"
          >
            <div class="dept-icon">
              <i :class="dept.icon"></i>
            </div>
            <h3 class="dept-name">{{ dept.name }}</h3>
          </div>
        </div>
      </div>
    </section>
    <!-- APP下载 -->
    <section class="app-section">
      <div class="container">
        <div class="app-container">
          <h2 class="app-title" v-animate-on-scroll>下载安心医疗APP</h2>
          <p class="app-description" v-animate-on-scroll>
            安装移动应用，随时随地预约挂号、查询报告、咨询医生，享受更便捷的就医体验
          </p>
          <div class="app-badges">
            <a href="#" class="app-badge" v-animate-on-scroll>
              <i class="fab fa-apple"></i>
              App Store下载
            </a>
            <a href="#" class="app-badge" v-animate-on-scroll>
              <i class="fab fa-android"></i>
              Android下载
            </a>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script lang="ts" setup>
// 所有一级科室数据
const allDepartments = [
  { id: 1, name: '内科', icon: 'fas fa-stethoscope' },
  { id: 2, name: '外科', icon: 'fas fa-scalpel' },
  { id: 3, name: '妇产科', icon: 'fas fa-female' },
  { id: 4, name: '儿科', icon: 'fas fa-child' },
  { id: 5, name: '眼科', icon: 'fas fa-eye' },
  { id: 6, name: '耳鼻喉科', icon: 'fas fa-ear' },
  { id: 7, name: '口腔科', icon: 'fas fa-tooth' },
  { id: 8, name: '皮肤科', icon: 'fas fa-allergies' },
  { id: 9, name: '中医科', icon: 'fas fa-leaf' },
  { id: 10, name: '康复科', icon: 'fas fa-wheelchair' },
  { id: 11, name: '急诊科', icon: 'fas fa-ambulance' },
  { id: 12, name: '精神心理科', icon: 'fas fa-brain' },
  { id: 13, name: '肿瘤科', icon: 'fas fa-plus-circle' },
  { id: 14, name: '感染科', icon: 'fas fa-virus' },
  { id: 15, name: '老年病科', icon: 'fas fa-user-md' }
]
</script>

<style scoped lang="scss">
// 基础样式变量
:root {
  --primary-blue: #0d6efd;
  --dark-blue: #0a58ca;
  --accent-teal: #20c997;
  --accent-purple: #6f42c1;
  --dark-purple: #5a32a3;
  --white: #ffffff;
  --light-gray: #f8f9fa;
  --text-dark: #212529;
  --text-medium: #6c757d;
  --text-light: #adb5bd;
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
  --transition: all 0.3s ease;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

// 搜索区域样式
.search-section {
  background: var(--primary-blue);
  padding: 60px 0 80px;
  position: relative;
  overflow: hidden;
  
  &::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: var(--white);
    border-radius: 40px 40px 0 0;
    transform: scaleX(1.2);
  }
}

.search-container {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.search-box {
  background: var(--white);
  border-radius: 60px;
  display: flex;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  height: 70px;
}

.search-input {
  flex: 1;
  border: none;
  padding: 0 30px;
  font-size: 1.1rem;
  outline: none;
  
  &::placeholder {
    color: var(--text-light);
  }
}

.search-button {
  background: var(--accent-teal);
  color: var(--white);
  border: none;
  padding: 0 35px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
  
  &:hover {
    // background: adjust-color(#20c997, $lightness: -8%);
  }
}

// 主功能区样式 - 已调整尺寸和样式
.features-section {
  padding: 50px 0 40px;
  background: var(--white);
  position: relative;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 25px;
  margin-top: 30px;
}

.feature-card {
  border-radius: 20px;
  padding: 40px 25px;
  color: var(--white);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  
  &:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
  }
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 100%);
  }
}

.feature-primary {
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
}

.feature-secondary {
  background: linear-gradient(135deg, #5a32a3 0%, #8a63d2 100%); /* 调整紫色渐变提高可读性 */
}

.feature-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  opacity: 0.9;
}

.feature-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 15px;
  position: relative;
  z-index: 2;
}

.feature-description {
  font-size: 1rem;
  margin-bottom: 25px;
  opacity: 0.9;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  z-index: 2;
}

.btn-white {
  background: var(--white);
  color: var(--primary-blue);
  padding: 12px 30px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 1rem;
  transition: var(--transition);
  text-decoration: none;
  display: inline-block;
  position: relative;
  z-index: 2;
  
  &:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
  }
}

// 所有科室区域样式
.all-departments-section {
  padding: 60px 0;
  background: var(--light-gray);
}

.section-header {
  text-align: center;
  margin-bottom: 40px;
}

.section-title {
  font-family: 'Poppins', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 15px;
}

.section-subtitle {
  font-size: 1.1rem;
  color: var(--text-medium);
  max-width: 600px;
  margin: 0 auto;
}

.departments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.dept-card {
  background: var(--white);
  border-radius: 15px;
  padding: 30px 15px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: pointer;
  
  &:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    
    .dept-icon {
      background: var(--primary-blue);
      color: var(--white);
    }
  }
}

.dept-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(13, 110, 253, 0.1);
  color: var(--primary-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 15px;
  transition: var(--transition);
}

.dept-name {
  font-family: 'Poppins', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
}

// APP下载区域样式
.app-section {
  padding: 80px 0;
  background: url('https://images.unsplash.com/photo-1581595219318-1a5f9f08f5b1?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80') center/cover no-repeat;
  position: relative;
  color: var(--white);
  text-align: center;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 27, 42, 0.85);
  }
  
  .app-container {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
  }
  
  .app-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2.2rem;
    margin-bottom: 20px;
  }
  
  .app-description {
    margin-bottom: 35px;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
  }
  
  .app-badges {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    
    @media (max-width: 768px) {
      flex-direction: column;
      align-items: center;
    }
  }
  
  .app-badge {
    display: inline-block;
    background: var(--white);
    border-radius: 10px;
    padding: 12px 25px;
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    font-size: 1rem;
    
    &:hover {
      transform: translateY(-3px);
      background: var(--primary-blue);
      color: var(--white);
    }
    
    i {
      margin-right: 8px;
      color: var(--primary-blue);
    }
    
    &:hover i {
      color: var(--white);
    }
    
    @media (max-width: 768px) {
      width: 220px;
    }
  }
}

// 动画效果
.animate {
  animation: fadeInUp 0.8s ease-out forwards;
  opacity: 0;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.delay-1 {
  animation-delay: 0.2s;
}

.delay-2 {
  animation-delay: 0.4s;
}

.delay-3 {
  animation-delay: 0.6s;
}

// 响应式调整
@media (max-width: 992px) {
  .feature-grid {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin: 30px auto;
    gap: 20px;
  }
  
  .feature-card {
    padding: 35px 25px;
  }
}

@media (max-width: 768px) {
  .search-box {
    height: 60px;
    
    .search-input {
      padding: 0 20px;
      font-size: 1rem;
    }
    
    .search-button {
      padding: 0 25px;
      font-size: 1rem;
    }
  }
  
  .departments-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
  }
  
  .dept-card {
    padding: 25px 10px;
  }
  
  .dept-icon {
    width: 50px;
    height: 50px;
    font-size: 20px;
    margin-bottom: 10px;
  }
  
  .dept-name {
    font-size: 0.95rem;
  }
  
  .app-section {
    padding: 60px 0;
  }
  
  .app-title {
    font-size: 1.8rem;
  }
}

.home-banner {
  position: relative;
  height: 340px;
  background: linear-gradient(120deg, #0d6efd 60%, #20c997 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  .banner-bg {
    position: absolute;
    inset: 0;
    background: url('/banner-medical.jpg') center/cover no-repeat;
    opacity: 0.13;
    z-index: 1;
  }
  .banner-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: #fff;
    .banner-logo {
      width: 70px;
      margin-bottom: 18px;
    }
    .banner-title {
      font-size: 2.2rem;
      font-weight: 700;
      margin-bottom: 10px;
      letter-spacing: 2px;
    }
    .banner-desc {
      font-size: 1.15rem;
      margin-bottom: 22px;
      opacity: 0.92;
    }
    .banner-btn {
      display: inline-block;
      background: #fff;
      color: #0d6efd;
      border-radius: 30px;
      padding: 12px 38px;
      font-size: 1.13rem;
      font-weight: 600;
      box-shadow: 0 4px 18px rgba(13,110,253,0.13);
      transition: background 0.2s, color 0.2s;
      &:hover {
        background: #20c997;
        color: #fff;
      }
    }
  }
}

.home-search-section {
  margin-top: -40px;
  display: flex;
  justify-content: center;
  .search-card {
    background: #fff;
    border-radius: 60px;
    box-shadow: 0 4px 18px rgba(13,110,253,0.10);
    display: flex;
    align-items: center;
    padding: 0 18px;
    height: 64px;
    max-width: 600px;
    width: 100%;
    .search-icon {
      font-size: 1.35rem;
      color: #0d6efd;
      margin-right: 10px;
      opacity: 0.85;
    }
    .search-input {
      flex: 1;
      border: none;
      outline: none;
      background: transparent;
      font-size: 1.13rem;
      color: #212529;
      height: 64px;
      padding: 0 10px;
    }
    .search-btn {
      border-radius: 0 60px 60px 0;
      font-weight: 600;
      padding: 0 38px;
      height: 48px;
      background: linear-gradient(90deg, #0d6efd, #20c997);
      color: #fff;
      border: none;
      font-size: 1.13rem;
      margin-left: 8px;
      transition: background 0.2s;
      &:hover {
        background: linear-gradient(90deg, #20c997, #0d6efd);
      }
    }
  }
}
</style>